import {Injectable} from '@angular/core';
import {AlertController} from '@ionic/angular';

@Injectable()

export class AlertComponent {

    constructor(public alertController: AlertController) {
    }

    public async presentAlert(message, buttonText = null) {
        let alert;
        if (buttonText) {
            alert = await this.alertController.create({
                cssClass: '',
                header: '温馨提示',
                message: message,
                buttons: [buttonText]
            });
        } else {
            alert = await this.alertController.create({
                cssClass: '',
                header: '温馨提示',
                message: message,
            });
        }
        await alert.present();
    }
}
